<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>同源的子页面</title>
  </head>
  <body>
    <h2>同源的子页面</h2>
    <script>
      /*
        子页面要获取父页面
          window.parent 就是父页面的window
          window.parent.document 就是父页面的document
      */
      const h1El = window.parent.document.querySelector("h1");
      console.log(h1El);
    </script>
  </body>
</html>
